﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cosmetic.Logic;
using Cosmetic.DataEntity;

namespace WebApp
{
    public partial class moreSubject : System.Web.UI.Page
    {
        private articleManger articlemanger = new articleManger();
        private articleclassManger articleClassManager = new articleclassManger();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Bind();
            }
        }

        private void Bind()
        {
            Bind1();
            Bind2();
        }

        private void Bind1()
        {
            List<articleclass> classes = articleClassManager.GetAll();

            articleclass class1 = classes.Where(c => c.name == "商城新闻").Single();

            this.lvNews1.DataSource = articlemanger.GetAlls(class1.id);
            this.lvNews1.DataBind();
        }

        private void Bind2()
        {
            List<articleclass> classes = articleClassManager.GetAll();
            articleclass class2 = classes.Where(c => c.name == "活动新闻").Single();

            this.lvNews2.DataSource = articlemanger.GetAlls(class2.id);
            this.lvNews2.DataBind();
        }

        protected void lvNews1_PagePropertiesChanged(object sender, EventArgs e)
        {
            Bind1();
        }

        protected void lvNews2_PagePropertiesChanged(object sender, EventArgs e)
        {
            Bind2();
        }
    }
}